using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.Mvc.Filters;
using ShopForWeb.Dto.ViewModels;
using ShopForWeb.UI.Extensions;

namespace ShopForWeb.UI.Filters;

public class ManagerInfoFilter : Attribute, IResultFilter
{
  public void OnResultExecuted(ResultExecutedContext context)
  {

  }

  //return View();结果之前
  public void OnResultExecuting(ResultExecutingContext context)
  {
    var controller = context.Controller as Controller;
    if (controller is not null)
      controller.ViewBag.Manager = context.HttpContext.Session.Get<ManagerViewModel>("manager");

  }
}
